import { Provide } from '@midwayjs/decorator';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { Book } from '../entity/book';

@Provide()
export class BookService {
  @InjectEntityModel(Book)
  bookModel: Repository<Book>;

  async getBooks() {
    return this.bookModel.find();
  }

  async addBook(book: Book) {
    return this.bookModel.save(book);
  }

  // 其他业务逻辑...
}